<?php
/* @var $this InvoiceController */
/* @var $model Invoice */

$this->breadcrumbs=array(
	'Invoices'=>array('index'),
	$modelInvoice->invoice_no,
);

$this->menu=array(
	array('label'=>'List Invoice', 'url'=>array('index')),
	array('label'=>'View Quotation', 'url'=>array('quotationOrderHeader/viewQuotationOrderHeader','id'=>$modelQuotation->quotation_no)),
	array('label'=>'Create Invoice', 'url'=>array('create')),
	array('label'=>'Update Invoice', 'visible'=>$modelInvoice->generate==0, 'url'=>array('update', 'id'=>$modelInvoice->invoice_no)),
	array('label'=>'Delete Invoice', 'visible'=>$modelInvoice->generate==0, 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$modelInvoice->invoice_no),'confirm'=>'Are you sure you want to delete this item?')),
);
?>

<h1>View Invoice <!-- #<?php echo $modelInvoice->invoice_no; ?> -->
<?php
	if($modelInvoice->generate==1){
		echo '<span class="label label-important"> Closed </span>';
	}
?>
</h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$modelInvoice,
	'attributes'=>array(
		'invoice_no',
		'date_invoice',
		'currency',
		array(
			'name'=>'accInvoice.bank',
			'value'=>$modelInvoice->account->bank,
         ),
		'due_date',
		'PO_reference',
	),
)); ?>

<table width="200px">
	<tr>
		<td>
		<p>
		<?php
			echo CHtml::beginForm( Yii::app()->createUrl('invoice/viewPDF&id='.$modelInvoice->invoice_no));
		?>
			<input type='submit' onclick="this.form.target='_blank';return true;" value='Generate' style="margin-left:20px;">
		<?php 
			echo CHtml::endForm();
		?>
		</p>
		</td>
		<?php 
			if($modelInvoice->generate==0){
		?>
		<td>
		<p>
		<?php 
			echo CHtml::beginForm( Yii::app()->createUrl('Invoice/close&id='.$modelInvoice->invoice_no));
		 	echo CHtml::submitButton('Finalize',array(
		 		'class'=>'pull-right',
			));  
			 echo CHtml::endForm();
		?>
		</p>
		</td>
		<?php } ?>
	</tr>
</table>